/**
 * 
 */
package game.rwalk.control;

import game.rwalk.R;
import game.rwalk.utility.Constants;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Paint.Style;

/**
 * @author sk8erboi
 *
 */
public class StatusGameScreen {
	
	//bitmaps
	private Bitmap bmpScore, bmpMenu, bmpMiss, bmpToken, bmpBoard;
	
	//define a paint for the bitmaps
	private Paint paint = new Paint();
	
	//define a paint for drawing text
	private Paint textPaint = new Paint();
	
	//game status
	public int score = 0, miss = 0;
	public String player;
	
	public StatusGameScreen(Context context) {
		
		//get Image from resource
		bmpScore = BitmapFactory.decodeResource(context.getResources(), R.drawable.score);
		bmpMenu = BitmapFactory.decodeResource(context.getResources(), R.drawable.menu);
		bmpMiss = BitmapFactory.decodeResource(context.getResources(), R.drawable.miss);
		bmpToken = BitmapFactory.decodeResource(context.getResources(), R.drawable.token);
		bmpBoard = BitmapFactory.decodeResource(context.getResources(), R.drawable.board2);
		
		//DEFINE RECTANGLE OF MENU
		
		textPaint.setARGB(255, 255, 255, 255);
		textPaint.setStyle(Style.FILL_AND_STROKE);
		textPaint.setTextSize(24);
	}
	
	public void onDraw(Canvas canvas) {
		
		//draw board
		canvas.drawBitmap(bmpBoard, 0, 0, paint);
		
		//draw player name
		if(player != null) {
			canvas.drawText(	player,
								Constants.SG_MARGIN_LEFT,
								Constants.SG_MARGIN_TOP,
								paint);
		}
		
		//draw score label
		canvas.drawBitmap(	bmpScore,
							150,
							Constants.SG_MARGIN_TOP,
							paint
						  );
		
		//draw score
		canvas.drawText(	Integer.toString(score),
							(float) 150 + Constants.SCORE_WIDTH,
							(float) Constants.SG_MARGIN_TOP + textPaint.getTextSize() ,
							textPaint);
		
		//draw menu button
		canvas.drawBitmap(	bmpMenu,
							Constants.SG_MENU_MLEFT,
							Constants.SG_MENU_MTOP,
							paint);
		
		//draw miss label
		canvas.drawBitmap(	bmpMiss,
							Constants.SG_MARGIN_LEFT,
							Constants.SG_MARGIN_TOP + Constants.SCORE_HEIGHT + Constants.SG_PADDING_TOP,
							paint);
		
		//draw token
		for(int i = 0; i < miss; i++) {
			canvas.drawBitmap(	bmpToken,
								Constants.MISS_WIDTH + Constants.SG_MARGIN_LEFT + (i + 1)*Constants.SG_PADDING_LEFT,
								Constants.SG_MARGIN_TOP + Constants.SCORE_HEIGHT + Constants.SG_PADDING_TOP,
								paint);
		}
	}
	
	public void hitMenu(int x, int y) {
		
	}
}
